package com.may.jwt.config;

import com.may.entity.TokenProperties;
import com.may.jwt.interceptors.JWTInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author May
 * @date 2020/11/10 13:43
 */
@Slf4j
@Configuration
public class JWTInterceptorConfig implements WebMvcConfigurer {
    @Resource
    TokenProperties tokenProperties;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns(tokenProperties.getPathPattern())
                .excludePathPatterns(tokenProperties.getExcludePathPattern());
    }
}
